#!/usr/bin/env python
# -*- coding:utf-8 -*-

##
# 站点栏目信息
#
class Catalog:
    id = 0
    sno = ''
    website_sno = ''
    seo_head = ''
    seo_key = ''
    seo_meta = ''
    seo_title = ''
    name = ''
    desp = ''
    create_time = None
    update_date = None
    status = ''


    DATA_COLUMN = ["id", "sno", "website_sno", "seo_head", "seo_key", "seo_meta", "seo_title", "name", "desp", "create_time", "update_date", "status"]
    TABLE_NAME = 'cms_catalog'

    def __init__(self):
        self.id = 0 
        self.sno = '' 
        self.website_sno = '' 
        self.seo_head = '' 
        self.seo_key = '' 
        self.seo_meta = '' 
        self.seo_title = '' 
        self.name = '' 
        self.desp = '' 
        self.create_time = None 
        self.update_date = None 
        self.status = '' 

    def myCatalog(self, id, sno, website_sno, seo_head, seo_key, seo_meta, seo_title, name, desp, create_time, update_date, status):
        self.id=id
        self.sno=sno
        self.website_sno=website_sno
        self.seo_head=seo_head
        self.seo_key=seo_key
        self.seo_meta=seo_meta
        self.seo_title=seo_title
        self.name=name
        self.desp=desp
        self.create_time=create_time
        self.update_date=update_date
        self.status=status


    @staticmethod
    def split_data_clum(with_id):
        ary = []
        if with_id:
            ary.append("id")
        [ary.append(item) for item in Catalog.DATA_COLUMN]
        return "`"+"`,`".join(ary)+"`"

    @staticmethod
    def split_params(params):
        g_param = []
        if params.id is not None and len(params.id) > 0:
            g_param.append('`id`='+"\'"+params.id+"\'")
        if params.sno is not None and len(params.sno) > 0:
            g_param.append('`sno`='+"\'"+params.sno+"\'")
        if params.website_sno is not None and len(params.website_sno) > 0:
            g_param.append('`website_sno`='+"\'"+params.website_sno+"\'")
        if params.seo_head is not None and len(params.seo_head) > 0:
            g_param.append('`seo_head`='+"\'"+params.seo_head+"\'")
        if params.seo_key is not None and len(params.seo_key) > 0:
            g_param.append('`seo_key`='+"\'"+params.seo_key+"\'")
        if params.seo_meta is not None and len(params.seo_meta) > 0:
            g_param.append('`seo_meta`='+"\'"+params.seo_meta+"\'")
        if params.seo_title is not None and len(params.seo_title) > 0:
            g_param.append('`seo_title`='+"\'"+params.seo_title+"\'")
        if params.name is not None and len(params.name) > 0:
            g_param.append('`name`='+"\'"+params.name+"\'")
        if params.desp is not None and len(params.desp) > 0:
            g_param.append('`desp`='+"\'"+params.desp+"\'")
        if params.create_time is not None and len(params.create_time) > 0:
            g_param.append('`create_time`='+"\'"+params.create_time+"\'")
        if params.update_date is not None and len(params.update_date) > 0:
            g_param.append('`update_date`='+"\'"+params.update_date+"\'")
        if params.status is not None and len(params.status) > 0:
            g_param.append('`status`='+"\'"+params.status+"\'")
        return ', '.join(str(i) for i in g_param)

    @staticmethod
    def to_string(with_flg):
        g_param = []
        if with_flg:
            g_param.append("`Catalog`.`id`")
            g_param.append("`Catalog`.`sno`")
            g_param.append("`Catalog`.`website_sno`")
            g_param.append("`Catalog`.`seo_head`")
            g_param.append("`Catalog`.`seo_key`")
            g_param.append("`Catalog`.`seo_meta`")
            g_param.append("`Catalog`.`seo_title`")
            g_param.append("`Catalog`.`name`")
            g_param.append("`Catalog`.`desp`")
            g_param.append("`Catalog`.`create_time`")
            g_param.append("`Catalog`.`update_date`")
            g_param.append("`Catalog`.`status`")
        else:
            g_param.append("id")
            g_param.append("sno")
            g_param.append("website_sno")
            g_param.append("seo_head")
            g_param.append("seo_key")
            g_param.append("seo_meta")
            g_param.append("seo_title")
            g_param.append("name")
            g_param.append("desp")
            g_param.append("create_time")
            g_param.append("update_date")
            g_param.append("status")
        return ', '.join(str(i) for i in g_param)

    @staticmethod
    def to_string_noId():
        g_param = []
        g_param.append("`Catalog`.`id`")
        g_param.append("`Catalog`.`sno`")
        g_param.append("`Catalog`.`website_sno`")
        g_param.append("`Catalog`.`seo_head`")
        g_param.append("`Catalog`.`seo_key`")
        g_param.append("`Catalog`.`seo_meta`")
        g_param.append("`Catalog`.`seo_title`")
        g_param.append("`Catalog`.`name`")
        g_param.append("`Catalog`.`desp`")
        g_param.append("`Catalog`.`create_time`")
        g_param.append("`Catalog`.`update_date`")
        g_param.append("`Catalog`.`status`")
        return ', '.join(str(i) for i in g_param)

    @staticmethod
    def chg_data_2_dict(with_id, obj):
        convert = dict()
        ary = []
        if with_id:
            ary.append("id")
        [ary.append(item) for item in Catalog.DATA_COLUMN]
        for clu_index in range(0, len(ary)):
            if ary[clu_index] == "id":
                convert[ary[clu_index]] == int(obj[clu_index])
            else:
                convert[ary[clu_index]] == str(obj[clu_index]).replace("	", "")
        return convert

    @staticmethod
    def chg_dict_2_data(with_id, obj):
        if with_id:
            data = [
                str(obj.id),
                str(obj.sno),
                str(obj.website_sno),
                str(obj.seo_head),
                str(obj.seo_key),
                str(obj.seo_meta),
                str(obj.seo_title),
                str(obj.name),
                str(obj.desp),
                str(obj.create_time),
                str(obj.update_date),
                str(obj.status),
            ]
        else:
            data = [
               str(obj.id),
               str(obj.sno),
               str(obj.website_sno),
               str(obj.seo_head),
               str(obj.seo_key),
               str(obj.seo_meta),
               str(obj.seo_title),
               str(obj.name),
               str(obj.desp),
               str(obj.create_time),
               str(obj.update_date),
               str(obj.status),
        ]
        return "'" + "','".join(data) + "'"